$(document).ready(function() {
    $('button[name^="password"]').click(function() {
        $('input[name^="password"]').val(generatePassword());
        return false;
        
    });
    
});
function generatePassword() {
    var length = 8,
            charset = "abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
            retVal = "";
    for (var i = 0, n = charset.length; i < length; ++i) {
        retVal += charset.charAt(Math.floor(Math.random() * n));
    }
    return retVal;
}

    var hash = CryptoJS.SHA256("Message");
